<%@page import="support.*, java.util.*, java.sql.*, java.lang.Integer"%>
<%@ page import="java.sql.*, javax.sql.*, javax.naming.*" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Admit or reject</title>
</head>
<body>
    <h1>User has received three reviews</h1>
    Decision:
    <!-- Drop down menu for the acceptance decision -->
    <form method="get" action="decision.do">
        <select name="decision">
            <option value="Pending">Pending</option>
            <option value="Accept">Accept</option>
            <option value="Reject">Reject</option>
        </select>
        <html:submit value="Submit" />
    </form>
    
    <!-- Maybe print out all the reviews pertaining to the user? -->
    <%
    final int NULL = 0;
    final int INTEGER = 4;
    final int DOUBLE = 8;
    final int STRING = 12;
    
    int studentid = (Integer)request.getSession(false).getAttribute("studentid");
    RowSet rset = (RowSet)request.getSession(false).getAttribute("application");
   // rset.relative(-2);
    ArrayList<ArrayList> reviewers = (ArrayList<ArrayList>)request.getSession(false).getAttribute("reviewers");
  /*  if(rset != null){
        out.print("<h1>Student " + studentid + " application</h1>");
        // get number of columns
        ResultSetMetaData rsetMeta = rset.getMetaData();
        int numCol = rsetMeta.getColumnCount();

        // make table/columns
        out.print("<table border=\"1\">");
        
        // print column names/labels
        for (int i =0; i<numCol; i++){
            out.print("<td>" + rsetMeta.getColumnLabel(i+1) + "</td>");
        }

        // print applications
        while(rset.next()){
            out.print("<tr>");
            // loop through columns
            for(int i = 0; i < numCol; i++){
                out.print("<td>");
                // type checks how to handle tuple information
                switch(rsetMeta.getColumnType(i+1)){
                  case NULL:
                      out.print("None");
                      break;
                  case INTEGER:
                      out.print(rset.getInt(i+1));
                      break;
                  case DOUBLE:
                      out.print(rset.getDouble(i+1));
                      break;
                  case STRING:
                      // checks if string is null (Strings have optional fields)
                      if(rset.getString(i+1) == null)
                          out.print("None");
                      else
                          out.print(rset.getString(i+1));
                      break;
                  default:
                      if(rset.getString(i+1) == null)
                          out.print("None");
                      else
                          out.print(rset.getString(i+1));
                }
                out.print("</td>");
            }
            out.print("</tr>");
        }
        out.print("</table>");
    }*/
    
    // print out all the previous reviewer information
    out.print("<br>Previous Reviews:<br>");
    out.print("<table border=1><tr><td>Reviewer</td><td>Grade</td><td>Comments</td></tr>");
    for(int i = 0; i < reviewers.size(); i++){
        ArrayList currentReviewer = reviewers.get(i);
        if((Integer)currentReviewer.get(3) == 1){
            out.print("<tr><td>" + currentReviewer.get(0) + "</td><td>" + currentReviewer.get(1) + "</td><td>" + currentReviewer.get(2) + "</td></tr>");
        }
    }
    out.print("</table><br><br>");
    %>
</body>
</html>